home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-18 | 2.4 KB | 69 lines | [TEXT/MPS ] |
- ********************************************************************************
- *
- * Apple Macintosh Developer Technical Support
- *
- * Exception-handling routines
- *
- * Program: GMundo
- * File: Exceptions.a
- *
- * by: Forrest Tanaka
- *
- * Copyright © 1988-1992 Apple Computer, Inc.
- * All rights reserved.
- *
- ********************************************************************************
-
- CASE ON
-
- ********************************************************************************
- * short ExceptionEntry(ExceptionPtr environment,
- * long *exceptionType,
- * long *exceptionCode);
- *
- * The exceptionType and exceptionCode pointers are saved in the environment
- * parameter, along with all the registers except D0, D1, A0, and A5.
- ********************************************************************************
-
- SEG 'Main'
- ExceptionEntry FUNC EXPORT
- MOVEA.L (SP)+,A1 ;Save ret addr
- MOVEA.L (SP),A0 ;Get ExceptionRec ptr
- MOVE.L $0004(SP),(A0)+ ;Save exceptionType ptr
- MOVE.L $0008(SP),(A0)+ ;Save exceptionCode ptr
- MOVEM.L D2-D7/A1-A4/A6/SP,(A0) ;Save registers,PC,SP
- MOVEQ #$0,D0 ;Set return val to 0
- JMP (A1) ;Return to caller
- ENDFUNC
-
- ********************************************************************************
- * void Exception(ExceptionPtr environment,
- * long exceptionType,
- * long exceptionCode);
- *
- * The exceptionType and exceptionCode parameters are placed into the
- * corresponding locations specified by the environment parameter. The registers
- * are then restored from the contents of the environment parameter. The flow
- * of control then jumps to the location that was saved in the environment
- * parameter.
- ********************************************************************************
-
- Exception PROC EXPORT
- MOVEA.L $0004(SP),A0 ;Get ExceptionRec ptr
- MOVE.L (A0),D0 ;Get exceptionType ptr
- BEQ.S @getExcCode ;If nil, skip setting
- MOVEA.L D0,A1 ;Need in A-reg to set
- MOVE.L $0008(SP),(A1) ;Set exceptionType
- @getExcCode
- MOVE.L $0004(A0),D0 ;Get exceptionCode ptr
- BEQ.S @restRegs ;If nil, skip setting
- MOVEA.L D0,A1 ;Need in A-reg to set
- MOVE.L $000C(SP),(A1) ;Set exceptionCode
- @restRegs
- MOVEQ #$F,D0 ;Set return val to -1
- MOVEM.L $0008(A0),D2-D7/A1-A4/A6/SP ;…
- ;Restore registers
- JMP (A1) ;Go to ExceptionEntry
- ENDPROC
-
- END